package authService

import (
	"roomAdmin/dao/authDao"
	"roomAdmin/models/authModel"
	"roomAdmin/utils/encryption"
)

func Login(loginMsg authModel.LoginMsg) (sign bool, role int, err error) {
	// 获取对应密码
	pwd, role, err := authDao.CheckLogin(loginMsg.UserName)
	if err != nil || pwd == ""{
		return
	}

	// 校验密码是否合法
	sign = encryption.ComparePasswords(pwd ,loginMsg.Password)
	return
}